# type()和isinstance()的区别
# type(obj):用于判断一个对象的类型
print(type(1))
print(type(1.1))
print(type(True))
print(type(-10))
print(type('1.1'))
print(type(0 + 0j))


# isinstance(obj1,obj2):用于在判定一个对象(obj1)是否是另一个给定类(obj2)的实例

a = 1
b = '1'
try:
    if isinstance(a, b):
        print('类型一样')
except Exception as e:
    print('类型不一样')


def num_test(num):
    if isinstance(num, (int, str, float, complex)):
        print('type:', type(num).__name__)
    else:
        print('error')


num_test(111)
num_test('')

